package edu.hawaii.teams.halealohacli.command;

import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;

/**
 * Tests the Utility class.
 * 
 * @author Branden Ogata
 * 
 */
public class TestUtility {

  /**
   * Tests the methods in the Utility class.
   * 
   * @throws Exception Handles any errors that do occur, such as timeouts.
   */
  @Test
  public void test() throws Exception {
    // Test the getDate method
    assertEquals("Testing year", Utility.getDate("2011-02-25", "year"), 2011);
    assertEquals("Testing month", Utility.getDate("2011-02-25", "month"), 2);
    assertEquals("Testing day", Utility.getDate("2011-02-25", "day"), 25);

    // Test the sorting algorithm
    List<String> sampleList = new ArrayList<String>();
    sampleList.add("Alpha 16");
    sampleList.add("Beta 12");
    sampleList.add("Gamma 18");

    sampleList = Utility.sortByEnergy(sampleList);
    assertEquals("Testing first value of sampleList", sampleList.get(0), "Beta 12");
    assertEquals("Testing second value of sampleList", sampleList.get(1), "Alpha 16");
    assertEquals("Testing third value of sampleList", sampleList.get(2), "Gamma 18");
  }
}